package test0109;

public class Test02 {
    public static void main(String[] args) {
        // (2)统计字符串中某个字符串出现的次数
        String s = "lskdabcjfsaabcdkfhwerwerabc";
        int i = m(s, "abc");
        System.out.println(i);
    }
    static int m(String string1,String string2){
        int count = 0;
        for (int i = 0; i<string1.length()-string2.length()+1;i++) {

            int j = i + string2.length();
            if (string1.substring(i,j).equals(string2)){
                count++;
            }
        }
        return count;
    }
}
